<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <include file="../Public/inc_header" />
        <title>{&SITE_TITLE}</title>
        <link href="../Public/images/base.css" rel="stylesheet" type="text/css" />
        <script>
            function post_vote(type){
                var most_vote_num = $("#most_vote_num").text();
                if(type == 0){
                    var opts = $('input[@name=vote_opt][@checked]').val();
                    var opts_ids = $('input[@name=vote_opt][@checked]').attr("id");
                }else{
                    var opts = '';
                    var opts_ids = '';
                    var num = 0;
                    $("input[@type=checkbox][@checked]").each(function(i){
                        opts += $(this).val()+",";
                        opts_ids += $(this).attr("id")+",";
                        num++;
                    });

        
                    if(num > most_vote_num){
                        alert("嗨，这个投票最多可投"+most_vote_num+"项");
                        return;
                    }
                }

                if(!opts){
                    alert("嗨，你到底投给哪一项呀？");
                    return false;
                }

                var URL = "__URL__";
                var vote_id = {$vote.id};
                $.post(URL+"/vote",{vote_id:vote_id,opts:opts,opts_ids:opts_ids},function(txt){
                    if(txt){
                        if(txt == "faild"){
                            alert("你已经投过一次了!");
                        }else if(txt == "not_fri"){
							alert("这个投票仅好友可投!");
						}else{
						    location.reload();
                        }
                    }
                });

            }

            $(function(){
                <php>
                    foreach($vote_pers as $k=>$v){
						if($v == 100) $v=97;
                        echo '$(".vote-per-'.$k.'").animate( { width: "'.$v.'%"}, 2000);';
                    }

                </php>

            });


        </script>
        <base target="_self" />
    </head>
    <body>
        <div id="doc"> <include file="../Public/space_inc_top" /> <include file="../Public/inc_left_bak" />
            <!-- Begin 主内容 -->
            <div class="contant-main">
                <h3 class="space-titile">投票</h3>
                <p class="return-lastpage"><a href="#"> </a></p>
                <div class="clearer"></div>
                <div class="contanter">
                    <ul id="member_favo_links">
                        <li><a  href="__URL__/index">发起投票</a></li>
                        <li><a href="__URL__/mine">我的投票</a></li>
                     <!--    <li><a href="__URL__/friend">好友的投票</a></li> -->
                        <li><a href="__URL__/random">随便看看</a></li>
                    </ul>
                    <div class="contant clear" style="padding:0;">
                        <div id="vote_contant">
                            <div class="vote-info">
                                <div id="author_face">
                                    <php>getNewUserFace($vote->user_id,50);</php>
                                </div>
                                <p><strong>{$vote.user_id|getUserName}发起的投票</strong><br />
                              <!--   <a href="__APP__/Home/index/id/{$vote.user_id}">他的首页</a> | <a href="__URL__/friend/uid/{$vote.user_id}">他的投票</a> --></p>
                            </div>
                            <ul class="message-list">
                                <li>发表时间：{$vote.cTime|friendlyDate}</li>
                                <li>已投票数：{$vote.vote_num}</li>
                                <li>截止时间：{$vote.deadline|friendlyDate}</li>
                            </ul>
                            <div class="clearer"></div>
                            <div class="vote-list">
                                <h3>{$vote.title}<span>(最多可选<span id="most_vote_num"><php>echo intval($vote->type)+1;</php></span>项)</span></h3>
                                <p class="dic">{$vote.explain}</p>
                                <div style="width: 520px;" class="polls">
                                    <form method="post" action="">
                                        <volist name="vote_opts" id="vo" key="k">
                                            <div class="pitem">
                                                <div class="psubject"> {$vo.name}:  </div>                                                
                                                <div class="barbg">
                                                    <div class="l"><img src="../Public/images/poll/v<php>$kk = $k%6;echo $kk?$kk:($kk+1);</php>.gif" style=" float:left;"  height="10"/></div>
                                                    <div class="l vote-per-{$k-1}" style="width: 0px;"  id="bg<php>$kk = $k%6;echo $kk?$kk:($kk+1);</php>"> </div>
                                                    <div class="l"><img src="../Public/images/poll/v<php>$kk = $k%6;echo $kk?$kk:($kk+1);</php>b.gif"  style=" position:relative;float:left;" height="10"/></div>
                                                </div>
                                                <div class="record"> {$vo.num}({$vote_pers[$k-1]}%) </div>
                                                <div class="iteminput">
                                                    <php>if($vote->type == 0){</php>
                                                    <input type="radio" name="vote_opt" value="{$vo.name}" id="{$vo.id}"/>
                                                    <php>}else{</php>
                                                    <input type="checkbox" name="vote_opt" value="{$vo.name}" id="{$vo.id}"/>
                                                    <php>}</php>

                                                </div>
                                            </div>
                                        </volist>
                                    </form>
                                </div>
                            </div>
                            <dl class="vote-list-friend-info">
                                <dt>好友的投票情况：</dt>
                                <volist name="vote_users" id="vo">
                                    <dd>
                                        <php>if($vo->user_id == $mid){</php>
                                        <img src="../Public/images/icon_friends_arrow.gif" width="10" height="11" alt="#" />
                                        <php>}</php>
                                        <a href="###">{$vo.user_id|getUserName}</a> {$vo.cTime|friendlyDate} 投票给
                                        <php>
                                            $rr = '';
                                            $s_opts = explode(",",$vo->opts);
                                            foreach($s_opts as $v){
                                                 $rr .=  '“'.$v.'”，';
                                            }
                                            echo rtrim($rr,'，');
                                        </php>
                                    </dd>
                                </volist>

                                <dt><br />
                                <!--仅 <a href="#">林玲</a> 的好友可以对此发表评论</dt>-->
                            </dl>
                            <input type="button" value="投票" class="button-saveset" onclick="post_vote({$vote.type})" style="cursor:pointer"/>
                        </div>
                        <div  class="js_blue_ln js_comment" id="comment"><h3 >评论</h3></div>
                        <div id="sendpmform" style="margin:10px;" >
						<script>
							function cm_check() {
								var xxx = $("#re_comment").val();
								xxx = $.trim(xxx);
								if(!xxx){
									alert("评论不能为空哦~!");
									return false;
								}
							}
						</script>
                            <form action="__URL__/comment" method="post" onsubmit="return cm_check()">

                                <p><label>内   &nbsp;&nbsp;容：</label>
                                    <!--<a href="#"><img style="vertical-align:top;" src="../Public/images/icon_face.png" width="28" height="17" alt="#" /></a>-->
									
                                    <textarea name="comment" cols="" rows="5" id="re_comment"></textarea>
                                    <input type="hidden" name="vote_id" value="{$vote.id}">
									<input type="hidden" id="toUserId" name="toUserId"/>
                                </p>
                                <div class="clearer"></div>
                                <p><label> &nbsp;</label><input name="" type="submit" value="发送" class="button" style="cursor:pointer"/></p>
                            </form>
                        </div>
                        <div  class="js_blue_ln js_mg10"></div>
                        <volist name="vote_comms" id="vo">
                            <div  class="js_blue_ln js_mg10 jsp20" >
                                <table width="90%" border="0" cellspacing="0" cellpadding="0"  class="jsmgl40">
                                    <tr valign="bottom">
                                        <td width="15%" rowspan="3" valign="middle">
                                            <div class="js_comment_face">
                                                {~getNewUserFace($vo->user_id,50)}
                                            </div>
                                        </td>
                                        <td width="54%" height="21"><strong><span  id="u_name_{$vo.id}">{$vo.user_id|getUserName}</span>说到：</strong></td>
                                        <td width="25%">&nbsp;</td>
                                        <td width="6%">&nbsp;</td>
                                    </tr>
                                    <tr  valign="top">
                                        <td height="5" colspan="3">{$vo.comment}</td>
                                    </tr>
									<div style="color:#999999;float:right;font-size:9px;width:80px;">{$vo.cTime|friendlyDate}</div>
                                    <tr  valign="bottom">
                                        <td height="23">
											<a href="javascript:huifu({$vo.user_id},{$vo.id})">回复</a> |
											<a href="__APP__/Message/send/to/{$vo.user_id}">短消息</a> 
											<php>if($vo->user_id == $mid){</php>
												|<a href="javascript:void(0)" onclick="del_comment({$vo.id});return false;">删除</a>
											<php>}</php>
										</td>
                                        <td height="23">&nbsp;</td>
                                        <td height="23">&nbsp;</td>
                                    </tr>
                                </table>
                            </div>
                        </volist>
					<script>
						function huifu(uid,cid) {
							var u_name = $("#u_name_"+cid).text();
							$("#toUserId").val(uid);
							$("#re_comment").val("回复"+u_name+"：").focus();
							
						}

						function del_comment(cid) {
							if(confirm("确定删除这条评论?")){
								location.href = URL + "/del_comment/id/"+cid;
							}
						}

					</script>

                    </div>
                </div>
            </div>
            <!-- End 主内容 -->
  <!-- begin 右侧信息 -->
            <div class="contant-sub">
            <include file="../Public/inc_right_bak" />
            </div>
            <!-- End 右侧信息 -->
            <div class="clear"></div>
        <include file="../Public/inc_footer" /> </div>
    </body>
</html>